﻿/////////////////////////////////////////////////////////////////////////
//                                                                     //
//    MTGProject - A Magic The Gathering Networked Environment         //
//                                                                     //
//      Copyright (c) 2008-2009 by The MTGProject Team (CSC230)        //
//                                                                     //
// This file is part of MTGProject.                                    //
//                                                                     //
// MTGProject is free software; you can redistribute it and/or         //
// modify it under the terms of the GNU Lesser General Public          //
// License as published by the Free Software Foundation; either        //
// version 3 of the License, or (at your option) any later version.    //
//                                                                     //
// This library is distributed in the hope that it will be useful,     //
// but WITHOUT ANY WARRANTY; without even the implied warranty of      //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       //
// GNU Lesser General Public License for more details.                 //
//                                                                     //
// You should have received a copy of the GNU Lesser General Public    //
// License along with this library; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA           //
// 02111-1307, USA, or contact the author(s):                          //
//                                                                     //
// Ruben Acuna <flyingfowlsoftware@earthlink.net>                      //
//                                                                     //
/////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using CSScriptLibrary;

namespace MTGProject
{
    public class CardSorcery : ICard
    {
        #region interface variables

        private string name;
        private LinkedList<ManaColor> cost;
        private LinkedList<ManaColor> colors;
        private string script;
        private string imageURL;
        private ICard parent;

        #endregion

        #region variables

        private IScriptCardSorcery scriptObject = null;

        #endregion

        #region interface properties

        public LinkedList<ManaColor> Cost
        {
            get { return cost; }
            set { cost = value; }
        }

        public LinkedList<ManaColor> Colors
        {
            get { return colors; }
            set { colors = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string Script
        {
            get { return script; }
            set { script = value; }
        }

        public string ImageURL
        {
            get { return imageURL; }
            set { imageURL = value; }
        }

        public ICard Parent
        {
            get { return parent; }
            set { parent = value; }
        }

        #endregion

        #region constructor

        public CardSorcery(string name, LinkedList<ManaColor> colors, LinkedList<ManaColor> cost, string script, string imageURL, ICard parent)
        {
            this.name = name;
            this.colors = colors;
            this.cost = cost;
            this.script = script;
            this.imageURL = imageURL;
            this.parent = parent;
        }

        #endregion

        #region interface methods

        //See ICard.
        public void StartScript(PlayerController controller)
        {
            if (File.Exists(Scripts.LOCATION + Script))
            {
                scriptObject = (IScriptCardSorcery)UtilScripts.Load(Scripts.LOCATION + Script, "CardScript");

                scriptObject.Start(this, controller);
            }
            else
                throw new IOException("Can't find script " + Scripts.LOCATION + Script);
        }

        #endregion

        #region interface scripting hooks

        //See ICard.
        public void OnResolve()
        {
            scriptObject.OnResolve();
        }

        //See ICard.
        public void OnPayCost()
        {
            scriptObject.OnPayCost();
        }

        #endregion
    }
}